﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DataCentral.Forms;

namespace DataCentral.UserControls
{
    public partial class DebtAdjustControl : DataCentral.CommonCenterControl
    {
        ValueListClass clValueList = new ValueListClass();
        public DebtAdjustControl()
        {
            InitializeComponent();
        }

        private void DebtAdjustControl_Load(object sender, EventArgs e)
        {
            dtpFromDate.DateTime = DateTime.Now.Date;
            dtpToDate.DateTime = DateTime.Now.Date;
            daDebtAdjust.Fill(dsCentral.DebtAdjust_Date, dtpFromDate.DateTime.Date, dtpToDate.DateTime.Date);
            iluSalePerson.DataSource = clValueList.GetSaleSysPersonList();
            iluCustomer.DataSource = clValueList.GetCustomerList();

            if (tabControl.SelectedTabPage == tabSalePerson)
            {
                viewSalePersonAdjust.ExpandAllGroups();
            }
            else
            {
                viewDebtCustomerAdjust.ExpandAllGroups();
            }
        }

        private void btnShow_Click(object sender, EventArgs e)
        {
            daDebtAdjust.Fill(dsCentral.DebtAdjust_Date, dtpFromDate.DateTime.Date, dtpToDate.DateTime.Date);

            if (tabControl.SelectedTabPage == tabSalePerson)
            {
                viewSalePersonAdjust.ExpandAllGroups();
            }
            else
            {
                viewDebtCustomerAdjust.ExpandAllGroups();
            }
        }

        private void btnDebtAdjust_Click(object sender, EventArgs e)
        {
            DebtAdjustForm frmDebtAdjust = new DebtAdjustForm();
            frmDebtAdjust.ShowDialog();
            btnShow_Click(null, null);
        }

        private void tabControl_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
        {
            daDebtAdjust.Fill(dsCentral.DebtAdjust_Date, dtpFromDate.DateTime.Date, dtpToDate.DateTime.Date);
            if (tabControl.SelectedTabPage == tabSalePerson)
            {
                viewSalePersonAdjust.ExpandAllGroups();
            }
            else
            {
                viewDebtCustomerAdjust.ExpandAllGroups();
            }
        }
    }
}
